package com.nineclock.document.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.document.DocumentControllerApi;
import com.nineclock.document.dto.DocFileDto;
import com.nineclock.document.dto.DocFolderDto;
import com.nineclock.document.dto.DocumentDto;
import com.nineclock.document.service.DocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.nineclock.document.dto.DocFileDto;
import com.nineclock.document.dto.DocFolderDto;
import com.nineclock.document.dto.DocumentDto;
import com.nineclock.document.service.DocumentService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping
public class DocumentController {

    @Autowired
    private DocumentService documentService;


    @GetMapping("/listFolderAndFile")
    public Result<DocumentDto> queryDocument(Long parentFoldId, String keyword) {
        DocumentDto documentDto = documentService.queryDocument(parentFoldId, keyword);
        return Result.success(documentDto);
    }


    @PostMapping("/insertFile")
    public Result createDoc(@RequestBody DocFileDto docFileDto) {
        documentService.createDoc(docFileDto);
        return Result.success();
    }


    @PostMapping("/insertFolder")
    public Result createFolder(@RequestBody DocFolderDto docFolderDto) {
        documentService.createFolder(docFolderDto);
        return Result.success();
    }


}

